// From http://dn.codegear.com/article/28432
#include <wchar.h>
#include <windows.h>
#include <iostream>
#include <QString>
#include <QMessageBox>

 #define ASSERTING(test,msg) \
  {                          \
        if (!(test))             \
        {                        \
          static int callIt=1;   \
          if (callIt)            \
          {                      \
            if (HandleAsserting(#test,#msg,__FILE__,__LINE__,&callIt)) \
            {                       \
                 \
            }                   \
          }                     \
        }                        \
  }


  int HandleAsserting(QString testStr, QString msgStr, QString fileStr, int line, int *callFlag)
  {
      msgStr = msgStr + QString('\n') + "occured on line number " + line + '\n' + "in file " + fileStr;
      QMessageBox *msgBox = new QMessageBox(QMessageBox::Critical, testStr, msgStr, QMessageBox::Retry);
      msgBox->addButton(QMessageBox::Ignore);
      msgBox->addButton(QMessageBox::Abort);
      switch(msgBox->exec())
      {
      case QMessageBox::Abort:
            return 1;
      case QMessageBox::Ignore:
            *callFlag = 0;
            return 0;
      }

      return 0;
  }

